package com.tjc.query;

/**
 * @Author: tjc
 * @description
 * @Date Created in 20:29 2022-06-16
 */
public class DBQuery {
    public enum OrderType {
        ASC("asc"),
        DESC("desc");

        private String value;

        OrderType(String value) {
            this.value = value;
        }
    }

    public static class DBConfig {
        private String url;
        private String username;
        private String password;
        private String driver;
        private String extParam;

        public DBConfig(String url, String username, String password, String driver, String extParam) {
            this.url = url;
            this.username = username;
            this.password = password;
            this.driver = driver;
            this.extParam = extParam;
        }
    }

    public static class Builder {
        private DBConfig config;
        private String[] columns;
        private String table;

        public Builder(DBConfig config) {
            this.config = config;
        }

        public Builder table(String table) {
            this.table = table;
            return this;
        }

        public Builder returnColumn(String... columns) {
            if (columns.length == 0) {
                throw new IllegalStateException("cannot select none column");
            }
            for (String c : columns) {
                if (null == c) {
                    throw new IllegalStateException("cannot select null");
                }
            }
            this.columns = columns;
            return this;
        }

        public Builder and() {
            return this;
        }

        public Builder or() {
            return this;
        }

        public Builder not() {
            return this;
        }

        public Builder desc(String... columns) {
            return this;
        }

        public Builder asc(String... columns) {
            return this;
        }

    }
}
